const WMTS_TOKEN = '3b41248c204d6f92ca4fbd7da0386da6'
const random = parseInt(Math.random() * 8)
const WMTS_LAYERS = [
  {
    id: '0',
    title: '天地图影像',
    name: 'wmts_img',
    layer: 'img',
    group: {
      id: 'imgLayerGroup',
      name: '影像图层组'
    },
    src: `http://t{0-7}.tianditu.gov.cn/img_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&TILEMATRIXSET=c&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&STYLE=default&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    baseUrl: `http://t${random}.tianditu.gov.cn/img_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    url: 'img',
  },
  {
    id: '1',
    title: '天地图影像注记',
    name: 'wmts_cia',
    layer: 'cia',
    group: {
      id: 'imgLayerGroup',
      name: '影像图层组'
    },
    src: `http://t{0-7}.tianditu.gov.cn/cia_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&TILEMATRIXSET=c&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&STYLE=default&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    baseUrl: `http://t${random}.tianditu.gov.cn/img_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    url: 'cia',
  },
  {
    id: '2',
    title: '天地图地形',
    name: 'wmts_ter',
    layer: 'ter',
    group: {
      id: 'terLayerGroup',
      name: '地形图层组'
    },
    src: `http://t{0-7}.tianditu.gov.cn/ter_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=ter&TILEMATRIXSET=c&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&STYLE=default&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    baseUrl: `http://t${random}.tianditu.gov.cn/ter_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=tre&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    url: 'ter',
  },
  {
    id: '3',
    title: '天地图地形注记',
    name: 'wmts_cta',
    layer: 'cta',
    group: {
      id: 'terLayerGroup',
      name: '地形图层组'
    },
    src: `http://t{0-7}.tianditu.gov.cn/cta_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cta&TILEMATRIXSET=c&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&STYLE=default&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    baseUrl: `http://t${random}.tianditu.gov.cn/cta_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cta&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    url: 'cta',
  },
  {
    id: '4',
    title: '天地图矢量',
    name: 'wmts_vec',
    layer: 'vec',
    group: {
      id: 'vecLayerGroup',
      name: '矢量图层组'
    },
    src: `http://t{0-7}.tianditu.gov.cn/vec_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&TILEMATRIXSET=c&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&STYLE=default&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    baseUrl: `http://t${random}.tianditu.gov.cn/vec_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    url: 'vec',
  },
  {
    id: '5',
    title: '天地图矢量注记',
    name: 'wmts_cva',
    layer: 'cva',
    group: {
      id: 'vecLayerGroup',
      name: '矢量图层组'
    },
    src: `http://t{0-7}.tianditu.gov.cn/cva_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&TILEMATRIXSET=c&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&STYLE=default&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    baseUrl: `http://t${random}.tianditu.gov.cn/cva_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=c&FORMAT=tiles&tk=${WMTS_TOKEN}`,
    url: 'cva',
  }
]

export const DEFAULT_PROJECTION = 'EPSG:4326' // WGS84

export const DEFAULT_OPTS = {
  target: 'map',
  center: [0, 0],
  // center: [116.39786526, 39.92421163],
  // EPSG:3857 (Web墨卡托)
  // EPSG:4326 (WGS84)
  // EPSG:4490 (CGCS2000)
  projection: DEFAULT_PROJECTION,
  wmtsLayers: WMTS_LAYERS,
  zoom: 16,
  minZoom: 3,
  maxZoom: 20,
  rotation: 0,
  scaleLine: true,
  mouseWheelZoom: true,
  doubleClickZoom: false,
  pinchRotate: true,
  pinchZoom: true
}
export const LAYER_GROUP_NAME = 'layerName'
export const GEO_LAYER_NAME = 'geoLayerName'
export const FEATURE_LAYER_ID = 'featureLayerId'
